package com.excellent.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.excellent.common.annotation.Log;
import com.excellent.common.enums.BusinessType;
import com.excellent.system.domain.SysStuExcellence;
import com.excellent.system.service.ISysStuExcellenceService;
import com.excellent.common.core.controller.BaseController;
import com.excellent.common.core.domain.AjaxResult;
import com.excellent.common.utils.poi.ExcelUtil;
import com.excellent.common.core.page.TableDataInfo;

/**
 * 卓越班管理Controller
 *
 * @author YYY
 * @date 2020-12-25
 */
@Controller
@RequestMapping("/system/excellence")
public class SysStuExcellenceController extends BaseController
{
    private String prefix = "system/excellence";

    @Autowired
    private ISysStuExcellenceService sysStuExcellenceService;

    @GetMapping()
    public String excellence()
    {
        return prefix + "/excellence";
    }

    /**
     * 查询卓越班管理列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysStuExcellence sysStuExcellence)
    {
        startPage();
        List<SysStuExcellence> list = sysStuExcellenceService.selectSysStuExcellenceList(sysStuExcellence);
        return getDataTable(list);
    }

    /**
     * 导出卓越班管理列表
     */
    @Log(title = "卓越班管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysStuExcellence sysStuExcellence)
    {
        List<SysStuExcellence> list = sysStuExcellenceService.selectSysStuExcellenceList(sysStuExcellence);
        ExcelUtil<SysStuExcellence> util = new ExcelUtil<SysStuExcellence>(SysStuExcellence.class);
        return util.exportExcel(list, "excellence");
    }

    /**
     * 新增卓越班管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存卓越班管理
     */
    @Log(title = "卓越班管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysStuExcellence sysStuExcellence)
    {
        return toAjax(sysStuExcellenceService.insertSysStuExcellence(sysStuExcellence));
    }

    /**
     * 修改卓越班管理
     */
    @GetMapping("/edit/{stuSno}")
    public String edit(@PathVariable("stuSno") String stuSno, ModelMap mmap)
    {
        SysStuExcellence sysStuExcellence = sysStuExcellenceService.selectSysStuExcellenceById(stuSno);
        mmap.put("sysStuExcellence", sysStuExcellence);
        return prefix + "/edit";
    }

    /**
     * 修改保存卓越班管理
     */
    @Log(title = "卓越班管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysStuExcellence sysStuExcellence)
    {
        return toAjax(sysStuExcellenceService.updateSysStuExcellence(sysStuExcellence));
    }

    /**
     * 删除卓越班管理
     */
    @Log(title = "卓越班管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysStuExcellenceService.deleteSysStuExcellenceByIds(ids));
    }
}
